<template>
	<view class="tabbar">
		<view class="top_center">
			<image :src="list[2].selectedIconPath" v-if="current == 2" alt=""></image>
			<image :src="list[2].iconPath" v-else alt=""></image>
		</view>
		<scroll-view class="scroll-view_H" scroll-x="true">
			<view class="scroll-view-item_H" v-for="(i, index) in list" :key="index" @click="changeTab(index)"
				:class="index == 2 ? 'centerView' : ''">
				<image class="u-page__item__slot-icon" :class="index == 2 ? 'centerImg' : ''" v-if="current == index"
					slot="active-icon" :src="i.selectedIconPath"></image>
				<image class="u-page__item__slot-icon" :class="index == 2 ? 'centerImg' : ''" v-else
					slot="inactive-icon" :src="i.iconPath"></image>
				<view class="text" :class="current == index ? 'active' : ''">{{ i.text }}</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		name: "tabbar",
		props: {
			current: {
				type: Number,
				default: 2
			}
		},

		data() {
			return {
				show: true,
				value1: 0,
				list: [{
						isCenter: false,
						"pagePath": "pages/liveAction/index",
						"iconPath": "",
						"selectedIconPath": "",
						"text": "实景"
					},
					{
						isCenter: false,
						"pagePath": "pages/Introduction/index",
						"iconPath": "",
						"selectedIconPath": "",
						"text": "攻略"
					},
					{
						isCenter: true,
						"pagePath": "pages/home/index",
						"iconPath": "",
						"selectedIconPath": "",
						"text": "首页"
					},
					{
						isCenter: false,
						"pagePath": "pages/culturalCreative/index",
						"iconPath": "",
						"selectedIconPath": "",
						"text": "文创"
					},
					{
						isCenter: false,
						"pagePath": "pages/mine/index",
						"iconPath": "",
						"selectedIconPath": "",
						"text": "我的"
					}
				],
			}
		},
		methods: {
			changeTab(e) {
				uni.switchTab({
					url: '/' + this.list[e].pagePath,
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.tabbar {
		position: fixed;
		left: 50%;
		transform: translateX(-50%);
		bottom: 40rpx;
		z-index: 99;
		display: flex;
		align-items: center;
		justify-content: space-around;
		flex-direction: column;
		width: 670rpx;
		height: 130rpx;

		.top_center {
			position: absolute;
			z-index: -10;
			top: 0;
			left: 50%;
			transform: translateX(-50%);
			width: 96rpx;
			height: 96rpx;
			background: #FFF;
			border-radius: 50% 50% 0 0;
			overflow: hidden;
			box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0,0,0,0.1);

			image {
				position: absolute;
				left: 50%;
				top: 4rpx;
				transform: translateX(-50%);
				width: 90rpx !important;
				height: 90rpx !important;
			}
		}

		.scroll-view_H {
			margin-top: 44rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0, 0, 0, 0.1);
			border-radius: 202rpx;

			height: 100rpx;
			white-space: nowrap;
			width: 100%;
			display: flex;
			align-items: center;

			.scroll-view-item_H {
				width: 20%;
				display: inline-block;
				height: 100rpx;
				text-align: center;
				padding-top: 10rpx;
			}
		}
	}


	.text {
		font-size: 20rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
	}

	.active {
		color: #0E9589;
	}

	image {
		height: 48rpx;
		width: 48rpx;
	}

	.centerImg {
		width: 90rpx !important;
		height: 90rpx !important;
		margin-top: -40rpx !important;
	}

	.centerView {
		height: 130rpx !important;
		margin-top: -40rpx !important;
	}
</style>
